﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using NZBMatrixAPI;


namespace AdaDaemon
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "AdaManager" in both code and config file together.
    public class AdaManager : IAdaManager
    {
        //TODO: nzbFile is current System -> ConnectStream. Why not the contents?
        //FIX: Perform API lookup within AdaMananger, not within AdaWeb!
        public bool AddDownload(string nzbID)
        {
            if (string.IsNullOrWhiteSpace(nzbID))
                return false;

            NZBMatrix nzbMatrix = new NZBMatrix(Ada.Protocol.Config.Instance.nzbMatrixUsername, Ada.Protocol.Config.Instance.nzbMatrixApiKey, true);

            string title = nzbMatrix.GetNZBDetails(nzbID).Name;

            return Program.newsgroupService.EnqueueNZB(nzbMatrix.GetNZBFile(nzbID), title);
            
        }
    }
}
